package com.siemens.industrial.model.admin;

import com.siemens.industrial.model.IUser;
import org.springframework.jdbc.core.RowMapper;

import java.util.Date;

/**
 * Created by weig on 8/23/16.
 */
public class User implements IUser{
    private String userId;
    private String userName;
    private int roleId;
    private String password;
    private int enabled;
    private String email;
    private String telephone;
    private String logoMd5;
    private String department;
    private String job;
    private String dashboardConfig;
    private int isFirstLogin;
    private Date createTime;
    private Date updateTime;

    private static final RowMapper<User> rowMapper = (resultSet, i) -> {
        User user = new User();
        user.setUserId(resultSet.getString("user_id"));
        user.setUserName(resultSet.getString("user_name"));
        user.setRoleId(resultSet.getInt("role_id"));
        user.setEmail(resultSet.getString("email"));
        user.setUserPwd(resultSet.getString("user_pwd"));
        user.setEnabled(resultSet.getInt("enabled"));
        user.setTelephone(resultSet.getString("telephone"));
        user.setLogoMd5(resultSet.getString("logo_md5"));
        user.setJob(resultSet.getString("job"));
        user.setDepartment(resultSet.getString("department"));
        user.setDashboardConfig(resultSet.getString("dashboard_config"));
        user.setCreateTime(new Date(resultSet.getTimestamp("create_time").getTime()));
        user.setUpdateTime(new Date(resultSet.getTimestamp("update_time").getTime()));

        return user;
    };

    public static RowMapper<User> getRowMapper() {
        return rowMapper;
    }

    //<editor-fold desc="getters and setters">

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public String getUserName() {
        return userName;
    }

    public void setUserPwd(String password) {
        this.password = password;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getTenant() {
        return null;
    }


    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    @Override
    public int getEnabled() {
        return enabled;
    }

    public void setEnabled(int enabled) {
        this.enabled = enabled;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getLogoMd5() {
        return logoMd5;
    }

    public void setLogoMd5(String logoMd5) {
        this.logoMd5 = logoMd5;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getDashboardConfig() {
        return dashboardConfig;
    }

    public void setDashboardConfig(String dashboardConfig) {
        this.dashboardConfig = dashboardConfig;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public int getIsFirstLogin() {
        return isFirstLogin;
    }

    public void setIsFirstLogin(int isFirstLogin) {
        this.isFirstLogin = isFirstLogin;
    }
    //</editor-fold>
}
